<%@page contentType="text/html;charset=utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>商品列表</title>
<link rel="stylesheet" type="text/css" href="css\list.css">
<script type="text/javascript">
	function showPreview(previewObj){
		var picture = $(previewObj).attr("data-picture");
		var pname = $(previewObj).attr("data-pname");
		Swal.fire({
			title:pname,
			html:"<img src='"+picture+"' style='width:361px;height:240px'>",
			showCloseButton:true,
			showConfirmButton:false
		});
	}

	function doDelete(goods_id){
		var flag = confirm("是否确定删除？");
		if (flag){
			//表明点了确定,访问Servlet。在当前页上打开超链接management?method=cdelete
			location.href="management?method=gdelete&goods_id="+goods_id;
		}
	}
</script>
</head>
<body>
	<div class="container">
		<fieldset>
			<legend>商品列表</legend>
			<div style="height: 40px">
				<a href="management?method=gshow_create" class="btn-button">新增</a>
			</div>
			<!-- 商品列表 -->
			<table cellspacing="0px">
				<thead>
					<tr style="width: 150px;">
						<th style="width: 150px;">名称</th>
						<th style="width: 100px;">分类</th>
						<th style="width: 100px;">起拍价</th>
						<th style="width: 400px">描述</th>
						<th style="width: 100px">加价幅度</th>
                        <th style="width: 100px">评估价</th>
						<th style="width: 150px">开拍时间</th>
                        <th style="width: 150px">结束时间</th>
						<th style="width: 150px">操作</th>
					</tr>
				</thead>
				<c:forEach items="${pageModel.pageData }" var="goods" >
					<tr>
						<td>${goods.goods_name }</td>
						<td>${goods.first_cname }-${goods.second_cname}</td>
						<td><fmt:formatNumber value="${goods.low_price }" pattern="￥,000.00"></fmt:formatNumber></td>
						<td>${goods.goods_desc }</td>
						<td><fmt:formatNumber value="${goods.price_markup }" pattern="￥,000.00"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${goods.appraisal_price }" pattern="￥,000.00"></fmt:formatNumber></td>
                        <td><fmt:formatDate value="${goods.start_time}" pattern="YYYY-MM-dd hh:mm:ss"></fmt:formatDate> </td>
                        <td><fmt:formatDate value="${goods.end_time}" pattern="YYYY-MM-dd hh:mm:ss"></fmt:formatDate> </td>
						<td>
							<a class="oplink" data-picture="${goods.goods_picture }" data-pname="${goods.goods_name }" href="javascript:void(0)" onclick="showPreview(this)">预览</a>
							<a class="oplink" href="management?method=gshow_update&goods_id=${goods.goods_id}">修改</a>
							<a class="oplink" href="#" onclick="doDelete(${goods.goods_id})">删除</a>
						</td>
					</tr>
				</c:forEach>
			</table>
			<!-- 分页组件 -->
			<ul class="page">
				<li><a href="management?method=glist&p=1">首页</a></li>
				<li><a href="management?method=glist&p=${pageModel.hasPreviousPage?pageModel.page-1:1 }">上页</a></li>
				<c:forEach begin="1" end="${pageModel.totalPages }" var="pno" step="1">
				<li ${pno==pageModel.page?"class='active'":"" }>
					<a href="management?method=glist&p=${pno }">${pno }</a>
				</li>
				</c:forEach>
				<li><a href="management?method=glist&p=${pageModel.hasNextPage?pageModel.page+1:pageModel.totalPages }">下页</a></li>
				<li><a href="management?method=glist&p=${pageModel.totalPages }">尾页</a></li>
			</ul>
		</fieldset>
	</div>

</body>
</html>
